#! venv/Scripts/python
# -*- coding: utf-8 -*-
import pygame


class BaseButton(pygame.Surface):
    """
    基础按钮类
    """

    def __init__(self, text, width=50, height=30, img_url="picture/button/button1.jpg", font_url="temp/simsun.ttc",
                 font_size=15):
        super(BaseButton, self).__init__(size=(width, height))
        self.Text = text
        self.Img = pygame.transform.scale(pygame.image.load(img_url), (50, 30))
        self.Font = pygame.font.Font(font_url, font_size)
        self.ButtonText = self.Font.render(self.Text, True, (255, 255, 255))
        self.Img.blit(self.ButtonText, (10, 8))
        self.blit(self.Img, (0, 0))

    def Change(self, text):
        self.Text = text
        self.ButtonText = self.Font.render(self.Text, True, (255, 255, 255))
        self.Img.blit(self.ButtonText, (10, 8))
        self.blit(self.Img, (0, 0))
